from socket import *

port = 12345
forwardIp   = '127.0.0.1'
forwardPort = 12346

# listen in network to get broadcast packets
s = socket(AF_INET, SOCK_DGRAM)
s.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
s.setsockopt(SOL_SOCKET, SO_BROADCAST, 1)
s.bind(('', port))

# forward
forwardAddress = (forwardIp, forwardPort)  
forwardSocket  = socket(AF_INET, SOCK_DGRAM)  

while True:
    data, address = s.recvfrom(1024)
    print "received %r from %r" % (data, address)
    forwardSocket.sendto(data, forwardAddress)
    
